<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
  <head>
    <title>
    </title>
    <meta charset="utf-8">
    <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="css/ui-btn.css">
    <link rel="stylesheet" href="css/ui-img.css">
    <link rel="stylesheet" href="css/ui-res.css">
    <link rel="stylesheet" href="css/ui-list.css">
    <link rel="stylesheet" href="css/ui-base.css">
    <link rel="stylesheet" href="css/ui-box.css">
    <link rel="stylesheet" href="css/ui-color.css">
	<link rel="stylesheet" href="css/style.css">
    <script src="js/zy_control.js"></script>
    <script src="js/zy_click.js"></script>
	<script src="js/dis_control.js"></script>
	<script src="js/zy_json.js"></script>
	<script src="js/zy_tmpl.js"></script>
	<script src="js/zy_anim.js"></script>
	<script src="js/zy_icache.js"></script>
	<script src="js/config.js"></script>
	<script src="js/dis_share.js"></script>
	<script src="js/zy_event.js"></script>
    <script>
	</script>
  </head>
<body class="um-vp c-gra5" ontouchstart id="myevt">
	<div class="us uc-a"></div>
	
	<div class="uc-n ub t-bla ub-ac lis uhide uinn" id="subject">    
	</div>
	<div class="" style="padding:0 .5em .5em .5em;" id="content">
	</div>
	
	<div class="umar-t" id="cmnum">
	</div>
	
	<!--回帖列表-->
	<div id="comlist" class="uhide">
		<div id="lists"></div>
		<!--回帖页跳转导航-->
		<div id="nav" ontouchstart="zy_cc(this);"></div>
	</div>

	<div style="height:2.5em"></div>
</body>
<script>
zy_init();
var params = getStorJson('params');
var aid = params.aid;
var windWH = '';
var favID = '';
var act = 0;
var curp = 1;
var totp = 1;
var subject = '';
var cnum  = 0;

window.uexOnload=function(type)
{
	windWH = "&width="+int(window.innerWidth*2/3)+"&height="+int(window.innerWidth*2/3);
	zy_initcache();
	setPageBounce('', '');
	
	setstorage('active', '');
	loadListPortal();
	addListen();
	//uescript('portal_detail', 'setNavDiv();');
}
function upcb(){
	resetBV('1');
}
function downcb(){
	resetBV('0');
}

/*文章内容*/
function loadListPortal(){
	var url = portal_url + "&mod=view&aid=" + aid +windWH;
	logs('portal-->url1='+url);
	if(!checkKey(url)) uexWindow.toast('1','5','加载中...',"");
	$.getJSON(url, loadListPortalCb, 'json', getJsonErr, 'POST', '', '1', '1');
}
function loadListPortalCb(json){
	uexWindow.closeToast();
	if(json){
		var o = json;
		cnum = o.commentnum;
		
		if(o.favorite){
			favID = o.favorite;
			//ueppscript('portal_detail', 'nav', 'favoriteUI(1)');
		}
		uescript('portal_detail', 'setNavDiv("'+favID+'");');
		act = 1;
		setstorage('active', '1');
		subject = o.title;
		
		var str1 = '<div class="ub-f1 ub ub-ver" id="'+o.catid+'">' 
			    	+'<div class="ulev0 uof-x">'+o.title+'</div>'		    
			    	+'<div class="ub ub-ac t-gra ulev-2" style="margin-top:.8em;"> '
				    	+'<div class="umh2 umw2 ub-img5 im3 lpic"></div> '
				    	+cnum
				    	+'<div class="umh2 umw2 ub-img5 im4 lpicl lpic"></div> '
				    	+'<div class="ub-f1">'+o.viewnum+'</div>'
						+'<div class="umh2 umw2 ub-img5 im5 lpicl lpic"></div>'
				    	+o.dateline
				    +'</div>'
				+'</div> ';
		setHtml('subject', str1);
		
		var str2 = '<div class="ubll"></div>' //'<img src="images/line.png" class="uh"/>'
					+'<div class="b-gra1 uof" style="padding:.5em;" onclick="hyperlinkHandle(event);" class="wba-all">'+o.content+'</div>'
					//+'<div style="position:relative;">'  /*广告位置*/
						//+'<img src="images/ad.jpg" class="uh umar-t" style="height:3em;" />'
						//+'<div class="recpic"><img src="images/recommend.png" style="height :1.5em;" /></div>'
					//+'</div>'
		setHtml('content', str2);
		
		onloadimg();
		
		var str3 = '<img src="images/plbg.png" class="recbg" />'
					+'<div class="t-wh ulev0 rectxt" id="replynum">'+cnum+'条评论</div>';
		setHtml('cmnum', str3);
		
		if(cnum>0) loadListCom('');
		else uexWindow.closeToast();
	}
}

function loadListCom(pn){
	var url = portal_url + "&mod=comment&aid=" + aid + "&page=" + pn
	$.getJSON(url, loadListComCb, 'json', getJsonErr, 'POST', '', '');
}
function loadListComCb(json){
	uexWindow.closeToast();
	if(json){
		var list = json.list;
		
		var tmpl = '<div class="b-gra uc-n ">'  	 
				 		+'<div ontouchstart="zy_touch(\'\')" class="uc-n ubb1 ub b-gra t-bla ub-ac lis">' 
							+'<div class="lis-th2 ub-img5 uc-a1 tx-c us">'
				     			+'<img src="${cb:img}" class="inforpic" id="pic${pid}"/>'
								+'<span class="t-gra ulev-1 tx-c">${cb:floor}</span>'
				     		+'</div>'  
				 			+'<div class="ub-f1 ub ub-ver">'	 
				 	    		+'<div class="ulev0" ><span>${username}</span><span class="ulev-1 t-gra ufr">${dateline}</span></div>'		    
				    			+'<div class="ulev-1 umh4 umar-t ulh1 uof">${message}</div>'
								+'<div class="ub">'
									+'<div class="ub-f1"></div>'
									+'<div class="t-gra7 ulev-1">&nbsp;&nbsp;</div>'
								+'</div>'
				 			+'</div>'      
				 		+'</div>'  
				  	+'</div>';
		var res = zy_tmpl(tmpl,list,zy_tmpl_count(list),j2vCb);
		
		//var cContent = $$('comlist');
		//var node = createEle("div");
		//node.innerHTML = res;
		//cContent.insertBefore(node,cContent.lastElementChild);
		setHtml('lists', res);
		
		onloadimg();
		
		var cp = json.zywy_curpage;
		var tp = json.zywy_totalpage;
		if(cp) curp = Int(cp);
		if(tp) totp = Int(tp);
		
		if(totp>1){
			var str = '<div class="pagebg ub ub-ac ub-pc">'
						+'<div class="uinn17 pagel ub-img5" ontouchstart="zy_touch(\'pagel-a\')" onclick="getNextPage(-1)"></div>'
						+'<div class="uinn17 pagebtn" ontouchstart="zy_touch(\'pagebtn-a\')" onclick="go2Page()">'+curp+'/'+totp+'</div>'
						+'<div class="uinn17 pager ub-img5" ontouchstart="zy_touch(\'pager-a\')" onclick="getNextPage(1)"></div>'
					+'</div>';
			setHtml('nav', str);
		}
	}
}

var fn = 1;
function j2vCb(d,c)
{
	var str = '';
	 if(c.length>1)
	 {
		switch(c[1])
		{
			case 'floor':
				if(fn==1) str='沙发';
				else if(fn==2) str='板凳';
				else if(fn==3) str='地板';
				else str=fn+'楼';
				str = '';
				fn++;
			break;
			case 'img':
			str = 'images/imgno.png';
			if(d.avatar){
				var pattern = /img src="(.*?)"/i; 
        		mts = pattern.exec(d.avatar); 
				if(mts) str=mts[1];
			}
			break;
		}
	 }
	 return str;
}

function favorite(){
	if(act){
		var url = '';
		if(favID){
			/*取消收藏*/
			url = home_url + "&mod=spacecp&ac=favorite&op=delete&deletesubmit=true&favid=" + favID;
		}
		else{
			/*添加收藏*/
			url = portal_url + "&mod=ajax&act=favorite&aid=" + aid;
		}
		uexWindow.toast('1','5','请稍候...','');
		$.getJSON(url, favoriteCb, 'json', getJsonErr, 'POST', '', '');
	}
	else uexWindow.toast('0','5','数据加载中，请稍候','2000');
}
function favoriteCb(json){
	if(json){
		var  str = '操作失败';
		if(favID){
			/*取消收藏*/
			if (json.status == '1') {
				favID = '';
				str = '取消收藏成功';
				ueppscript('portal_detail', 'nav', 'favoriteUI()');
				setMyData(1, '');
			}else{
				if(json.message) str = json.message;
			}
		}
		else{
			/*添加收藏*/
			if(json.message) str = json.message;
			else{
				favID = json;
				str = '收藏成功';
				ueppscript('portal_detail', 'nav', 'favoriteUI(1)');
				setMyData(1, favID);
			}
		}
		uexWindow.toast('0','5',str, 2000);
	}
}

function getNextPage(cmd){
	var np = 0;
	if(cmd==-1){
		if(curp>1) np=curp-1;
	}
	else{
		if(curp<totp) np=curp+1;
	}
	if(np>0){
		uexWindow.toast('1','5','加载中...',"");
		loadListCom(np);
	}	
}

function go2Page(){
	var keycap = ['确定','取消'];
	uexWindow.cbPrompt = function (opId, dataType, data){
		var objdata = eval('('+data+')');
		if(objdata.num==0){
			var num = int(objdata.value);
			if(0<num && num<=totp) loadListCom(num);
			else uexWindow.alert('提示', '输入错误！', '确定');

        }
	}
	uexWindow.prompt('请输入页码：','请输入页码：', '', keycap);
}

var ii = 0;
function onloadimg(){
	var ee = document.getElementsByTagName("img");
	var imgsrc = '';
	for(var key in ee)
	{
		var eimage = ee[key];
		imgsrc = eimage.src;
		if(imgsrc && imgsrc.indexOf('http://')==0 && imgsrc.indexOf('.gif')<0 && !eimage.id)
		{
			var id = "img_"+ii;
			eimage.src = 'images/mylogo.gif';
			eimage.id = id;
			
			var imgs = imgsrc.split('&src=');
			if(imgs && imgs[1]) imgs = imgs[1];
			else imgs = imgsrc;
			imglists[ii] = imgs;
			//logs('portal_detail::onloadimg-->imgs='+imgs);
			dis_imgcache(id,imgsrc,imgsrc,imgLoadSucSrc,imgLoadErrSrc,null,'');
			ii++;
		}
	}
}

function readArtOnly(){
	zy_anim_pop('content', 'uhide');
	zy_anim_push('comlist', 'uhide');
	
	var e = document.body;
	e.scrollTop = 0;
}

function readComOnly(){
	zy_anim_push('content', 'uhide');
	zy_anim_pop('comlist', 'uhide');
	
	var e = document.body;
	e.scrollTop = 0;
}

function weiboShare(){
	if(act){
		uid = getstorage('UID');
		var url = serverurl+'portal.php?&mod=view&aid=' + aid;
		sharestart(url, uid, subject, 'portal_detail');
	}
}

function update5(){
	logs('success ~ ~ ~');
	cnum++;
	setHtml('replynum',cnum+"条评论");
	loadListCom('');
	setMyData(0, '');
}

function setMyData(id, val){
	var key = portal_url + "&mod=view&aid=" + aid +windWH;
	var obj = getStorJson(key);
	if(obj){
		if(id==0) obj.commentnum = cnum;
		else if(id==1) obj.favorite = val;
		setStorJson(key, obj);
	}
}

var myEvt = null;
function addListen(){
	if(!isSML && !myEvt) 
		myEvt = new zyEvent('myevt',moveCb,endCb,0,null);
}
function moveCb(ele,dX,dY){
	logs('moveCb()--------dX='+dX+', dy='+dY);
	if(act && dY<-10){
		var sc = getstorage('fscreen');
		if (!sc) {	
			uescript('portal_detail', 'openFscr();');
			act = 0;
			setTimeout('act=1;', 500);
		}
	}
}
function endCb(e,dX,dY,t){
	logs('endCb()--> dX='+dX+', dY='+dY+', t='+t);
	/*var sc = getstorage('fscreen');
	if (!sc) {
		event.preventDefault();
		event.stopPropagation();
		
		if (t != 'down') {//(dX>10 || dY>10)
			uescript('portal_detail', 'openFscr();');
			act = 0;
			setTimeout('act=1;', 500);
		}
	}*/
}

function moveOutsc(){
	var hh = getstorage('headerHeight');
	var dy = hh;
	var fsc = getstorage('fscreen');
	if(fsc) dy = '-'+hh;
	
	logs('portal_detail_content-->moveOutsc()-->dy='+dy);
	
	disShowAnim('0', dy);
}

</script>
</html>
